package com.jy.wms.controller;

import com.jy.wms.common.SetStatus;
import com.jy.wms.common.base.ServiceException;
import com.jy.wms.pojo.WmsCustomerFile;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.jy.wms.common.base.BaseController;
import com.jy.wms.common.base.JsonResult;
import com.jy.wms.pojo.WmsAddressDictionary;
import com.jy.wms.service.WmsAddressDictionaryService;
import javax.servlet.http.HttpSession;
import com.github.pagehelper.Page;
import com.jy.wms.common.base.ResultPage;
import java.util.List;
import java.util.Map;

import com.jy.wms.common.UUIDUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @ClassName: WmsAddressDictionaryController
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @Author Liyi
 * @Date Sat Oct 14 09:29:55 CST 2017
 */
@RestController
@RequestMapping("/wmsAddressDictionary")
@Api(value = "/wmsAddressDictionary", description = "关于城市操作")
public class  WmsAddressDictionaryController extends BaseController<WmsAddressDictionaryService,WmsAddressDictionary> {

    @ApiOperation(value = "城市操作 查询所有省",response = JSONObject.class, notes = "查询所有省")
    @GetMapping(value = "/province")
    public @ResponseBody JSONArray province(){
        try {
            List<Map<String,Object>> map = baseService.baseSelectAllProvince();
            return JSONArray.fromObject(map);
        } catch (ServiceException e) {
            e.printStackTrace();
            return JSONArray.fromObject(SetStatus.setReturn(0, false, 1, "城市操作", e.getMessage(), ""));
        } catch (Exception e) {
            e.printStackTrace();
            return JSONArray.fromObject(SetStatus.setReturn(0, false, 1, "城市操作", "查询所有省", ""));
        }

    }

    @ApiOperation(value = "城市操作 根据省ID查询所有的城市",response = JSONObject.class, notes = "根据省ID查询所有的城市")
    @GetMapping(value = "/city/{fjid}")
    public @ResponseBody JSONArray city(@PathVariable("fjid") String fjid){
        try {
            List<Map<String,Object>> map = baseService.baseSelectCityByFjid(fjid);
            return JSONArray.fromObject(map);
        } catch (ServiceException e) {
            e.printStackTrace();
            return JSONArray.fromObject(SetStatus.setReturn(0, false, 1, "城市操作", e.getMessage(), ""));
        } catch (Exception e) {
            e.printStackTrace();
            return JSONArray.fromObject(SetStatus.setReturn(0, false, 1, "城市操作", "根据省ID查询所有的城市", ""));
        }

    }
}
